package com.wanxi.spring.cloud.permission.controller;


import com.wanxi.spring.cloud.commons.api.CommonResult;
import com.wanxi.spring.cloud.permission.model.Permission;
import com.wanxi.spring.cloud.permission.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 蒋帆
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    PermissionService permissionService;

//    @GetMapping("/getPermissions")
//    public CommonResult getPermissions(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit){
//        return permissionService.getPermissions(page,limit);
//    }
    @GetMapping("/getPermissions")
    public CommonResult getPermissions(@RequestParam Map map){
        return permissionService.getPermissions(map);
    }

    @GetMapping("/getAllPermissions")
    public CommonResult getAllPermissions(){
        return permissionService.getAllPermissions();
    }

    @PostMapping("/addPermission")
    public CommonResult addPermission(@RequestBody Permission permission){
        return permissionService.addPermission(permission);
    }

    @PostMapping("/updatePermission")
    public CommonResult updatePermission(@RequestBody Permission permission){
        return permissionService.updatePermission(permission);
    }

    @DeleteMapping("/deletePermission")
    public CommonResult deletePermission(@RequestParam Integer id){
        return permissionService.deletePermission(id);
    }
}
